﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Reflection;
using System.Configuration;

namespace KingSite.Library.Safe {

    public class AntiXSSHelper {
        static IAntiXSSSetting zipSetting = new AntiXSSSetting();

        public static IAntiXSS GetInstance() {
            string[] type = zipSetting.AntiXssType.Split(',');
            string a = type[1];
            string n = type[0];
            Assembly ass = Assembly.Load(a);
            Type[] t = ass.GetTypes();
            object o = ass.CreateInstance(n);
            return (IAntiXSS)o;
        }
    }

    public interface IAntiXSSSetting {
        string AntiXssType { get; }
    }

    public class AntiXSSSetting : IAntiXSSSetting {
        public string AntiXssType {
            get { return ((NameValueCollection)ConfigurationManager.GetSection("KingSiteLibrary/Safe"))["AntiXSSType"]; }
        }
    }
}
